package com.hmall.item.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hmall.item.mapper.ItemMapper;
import com.hmall.item.pojo.Item;
import com.hmall.item.service.IItemService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ItemService extends ServiceImpl<ItemMapper, Item> implements IItemService {

    @Override
    @Transactional
    public void updateStatus(long id, Integer status) {
     /*   Item item = new Item();
        item.setId(id);
        item.setStatus(status);
        this.getBaseMapper().updateById(item);*/
        this.update()
                .set("status",status)
                .eq("id",id)
                .update();
    }

    @Override
    @Transactional
    public void updateItem(Item item) {

        this.update()
                .set("name",item.getName())
                .set("category",item.getCategory())
                .set("brand",item.getBrand())
                .set("price",item.getPrice())
                .set("stcok",item.getStock())
                .set("spec",item.getStock())
                .set("image",item.getImage())
                .set("isAD",item.getIsAD())
                .update();



    }

    @Override
    @Transactional
    public void deleteById(long id) {
        this.deleteById(id);

    }

}
